
#include <stdio.h>
#include <system/application.h>
#include <graphics/sprite.h>
#include <maths/vector2.h>
#include <maths/vector3.h>
#include <vector>
#include <graphics/mesh_instance.h>
#include <graphics/vita/texture_vita.h>
#include <graphics/model.h>

#include "GameState.h"
#include "GameOverState.h"



GameOverState::GameOverState(const abfw::Platform& platform)
{
	mFont = new abfw::Font();
	mFont->Load("comic_sans", platform);

	mInputManager = platform.CreateSonyControllerInputManager();
}

GameOverState::~GameOverState()
{
	delete mInputManager;
}

//-- Set the final player score for printing to screen
void GameOverState::SetPlayerScore(int value)
{
	mFinalScore = value;
}

//-- Update the game over state
GameStates::State GameOverState::Update() 
{						
	//-- Update controls
	mInputManager->Update();

	//-- If the player presses Cross in this state
	if (mInputManager->buttons_down() & ABFW_SONY_CTRL_CROSS)
	{
		//-- Restart the game
		return GameStates::MENUSTATE;
	}

	return GameStates::GAMEOVERSTATE;
}

void GameOverState::Draw2D(abfw::SpriteRenderer* render, abfw::Matrix44 Projection) 
{
	//-- Draw a screen similar to the menu
	if(mFont)
	{
		mFont->RenderText(render, abfw::Vector3(190.0f, 50.0f, -0.9f), 3.0f, 0xff0000ff, abfw::TJ_LEFT, "Space Commander");
		mFont->RenderText(render, abfw::Vector3(480.0f, 350.0f, -0.9f), 1.0f, 0xff0000ff, abfw::TJ_CENTRE, "Left Analogue Stick: Move");
		mFont->RenderText(render, abfw::Vector3(480.0f, 390.0f, -0.9f), 1.0f, 0xff0000ff, abfw::TJ_CENTRE, "Right Analogue Stick: Aim");
		mFont->RenderText(render, abfw::Vector3(480.0f, 440.0f, -0.9f), 1.0f, 0xff0000ff, abfw::TJ_CENTRE, "Right Shoulder Button: Shoot");

		mFont->RenderText(render, abfw::Vector3(480.0f, 202.0f, -0.9f), 1.0f, 0xffffffff, abfw::TJ_CENTRE, "Game Over! Your score was %i", mFinalScore);
		mFont->RenderText(render, abfw::Vector3(480.0f, 242.0f, -0.9f), 1.0f, 0xffffffff, abfw::TJ_CENTRE, "Press X to play again!");
	}

}
void GameOverState::Draw3D(abfw::Renderer3D* render, abfw::Colour defaultColour) 
{
	
}


